package com.gxa.ssm340.controller;

import com.gxa.ssm340.common.R;
import com.gxa.ssm340.entity.pojo.Coupon;
import com.gxa.ssm340.entity.vo.MyCpnSelectVO;
import com.gxa.ssm340.service.CpnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @BelongsProject: huanlianchaoshi
 * @Author: Donglu
 * @CreateTime: 2023-10-24  17:02
 */
@Api(value = "CpnController",tags = "我的优惠券")
@RequestMapping("/user")
@RestController
public class MyCpnController {
    @Autowired
    private CpnService cpnService;

    @ApiOperation("我的优惠券界面")
    @PostMapping("/cpnListForWeb")
    public R selectAllCpn(@RequestParam("phone") String phone) {
        List<Coupon> overExpire = cpnService.selectMyOverExpire(phone);
        List<Coupon> userGetCpnIsUsedList = cpnService.selectUsedCpn(phone);

        MyCpnSelectVO myCpnSelectVO = new MyCpnSelectVO();
        myCpnSelectVO.setOverExpire(overExpire);
        myCpnSelectVO.setUserGetCpnIsUsedList(userGetCpnIsUsedList);

        return R.success(myCpnSelectVO);

    }
}
